<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>组件补充</h2>
      <child></child>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      // data现在必须要写成函数并且返回对象
      // 目的是为了组件在复用的时候，每一个组件都只维护自己的数据的变化
      const Child = {
        data() {
          return {
            count: 10,
          };
        },
        template: `
          <div>child子组件 - {{ count }}</div>
          <p>123</p>
        `,
      };

      const app = createApp({
        components: {
          Child,
        },
      });

      app.mount("#app");
    </script>
  </body>
</html>

<!-- <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>组件补充 - vue2</h2>
      <child></child>
    </div>

    <script src="./lib/vue2.js"></script>
    <script>
      const Child = {
        template: `
          <div>
            <div>child子组件</div>
            <p>123</p>
          </div>
        `,
      };

      new Vue({
        components: {
          Child,
        },
      }).$mount("#app");
    </script>
  </body>
</html> -->
